﻿using System;
using Common.Logging;
using System.Reflection;

namespace DotNetNexusSpam
{
    class ProgramUtil
    {
        public static bool GetCommandLineArgs(ref string idEmail, ref string connectorCode)
        {
            ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 

            bool argsAreFromCommandLine = false;
            if (!(idEmail.Length > 0 && connectorCode.Length > 0)) {
                if (Environment.GetCommandLineArgs().Length > 1)
                {
                    idEmail = Environment.GetCommandLineArgs()[1];
                    connectorCode = Environment.GetCommandLineArgs()[2];
                    argsAreFromCommandLine = true;
                }
                else
                {
                    //Console.WriteLine("****");
                    Console.Write("\n\nPlease provide email's ID: ");
                    idEmail = Console.ReadLine();
                    Console.Write("");
                    Console.Write("Please provide connector's code: ");
                    connectorCode = Console.ReadLine();
                    Console.WriteLine("\n");
                }    
            }
            return argsAreFromCommandLine;
        }
    }
}
